<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreatePermissionTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('permission', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->unsignedTinyInteger('type')->default('0')->comment('类型：1模块 2权限');
            $table->unsignedTinyInteger('public_type')->default('0')->comment('权限通用类型：0无 1登录 2模块通用 3公共');
            $table->unsignedInteger('parent_id')->default('0')->comment('上级权限');
            $table->string('name', 30)->default('')->comment('权限名称');
            $table->string('priv', 200)->default('')->comment('权限（对应后端路由别名）');
            $table->string('uri')->default('')->comment('接口（对应后端路由uri）');
            $table->string('request_methods', 50)->default('')->comment('请求方法：GET、POST等');
            $table->string('controller')->default('')->comment('所属模块');
            $table->string('controller_method')->default('')->comment('模块方法');
            $table->string('description', 200)->default('')->comment('描述描述');
            $table->unsignedInteger('sort')->default('999')->comment('排序位置');
            $table->tinyInteger('status')->default(1)->comment('发布状态，0未发布，1已发布 ，数据字典');
            $table->integer('created_user_id')->default(0)->comment('管理员ID');
            $table->timestamp('created_at')->nullable()->comment('创建时间');
            $table->timestamp('updated_at')->nullable()->comment('更新时间');
            $table->softDeletes()->comment('删除时间');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('permission');
    }
}
